#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	string a;
	int n, r = -1, q = 0, l = 0;
	cin >> a;
	n = end(a) - begin(a);
	vector <int> b;
	vector <int> c;
	for (int i = 0; i < n; i++) {
		if (a.at(i) == '(') {
			b.push_back(1);
			l++;
		}
		else if (a.at(i) == ')') {
			b.push_back(2);
			l++;
		}
		else if (a.at(i) == '[') {
			b.push_back(3);
			l++;
		}
		else if (a.at(i) == ']') {
			b.push_back(4);
			l++;
		}
		else if (a.at(i) == '{') {
			b.push_back(5);
			l++;
		}
		else if (a.at(i) == '}') {
			b.push_back(6);
			l++;
		}
		else if (a.at(i) == '<') {
			b.push_back(7);
			l++;
		}
		else if (a.at(i) == '>') {
			b.push_back(8);
			l++;
		}
	}
	for (int i = 0; i < l; i++) {
		if (b[i] % 2 == 1) {
			r++;
			c.push_back(0);
			c[r] = b[i];
		}
		else {
			if (r != -1 and c[r] + 1 == b[i]) {
				r--;
			}
			else {
				q = 1;
				break;
			}
		}
	}
	if (q == 0 and r == -1) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}